<?php
/**
 * Created by PhpStorm.
 * User: nhson219
 * Date: 9/17/14
 * Time: 1:59 PM
 */
?>
<div class="modal fade" id="modaldeniedMilestone<?php echo $id?>">
    <div class="modal-dialog">
        <div class="modal-content">
            <div class="modal-header">
                <button type="button" class="close" data-dismiss="modal"><span aria-hidden="true">&times;</span><span class="sr-only">Close</span></button>
                <h4 class="modal-title"><?php echo $this->lang->line('Confirm Send Request')?></h4>
            </div>
            <div class="modal-body">
                <textarea class="form-control" id="deniedMessage<?php echo $id;?>" placeholder="Gửi tin nhắn" rows="3"></textarea>
            </div>
            <div class="modal-footer">
                <button type="button" class="btn btn-default" data-dismiss="modal">Close</button>
                <button type="button" class="btn btn-primary" id="btn-deniedMilestone<?php echo $id;?>"><?php echo $this->lang->line('Send')?></button>
            </div>
        </div><!-- /.modal-content -->
    </div><!-- /.modal-dialog -->
</div><!-- /.modal -->
<script>
    $("#btn-deniedMilestone<?php echo $id?>").click(function(){
        $.ajax({
            type: "POST",
            url: "<?php echo base_url()."index.php/project/deniedDevRequestMilestone"?>",
            data: {'message' : $("#deniedMessage<?php echo $id?>").val() , 'milestone_id' : <?php echo $id?>},
            beforeSend: function () {
                $('#loading-image').show();
            },
            success: function (data) {
                $('#loading-image').hide();
                data = $.parseJSON(data);
                if(data.status == 'error'){

                }else{
                    window.location = BASE_URL+"/index.php/project/view/"+data.project_id;
                }
            }
        });
        $('#modaldeniedMilestone<?php echo $id?>').modal('hide')
    });
</script>